package com.mwh.yuantu.dao;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mwh.yuantu.dao.mapper.CommentInfoMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mwh.yuantu.entity.CommentInfoEntity;

/**
 * (CommentInfo)表数据库访问层
 *
 * @author maweihong
 * @since 2023-11-01 09:47:29
 */
@Service
public class CommentInfoDao extends ServiceImpl<CommentInfoMapper , CommentInfoEntity> {

    @Autowired
	private CommentInfoMapper commentInfoMapper;

    /**
     * 插入新的评论
     * @param commentInfo
     * @return
     */
    public int insert(CommentInfoEntity commentInfo){
        return commentInfoMapper.insert(commentInfo);
    }

    /**
     * 获取某个视频的评论列表
     * @param videoId 视频主键
     * @return
     */
    public List<CommentInfoEntity> listByVideoId(String videoId){
        return commentInfoMapper.listByVideoId(videoId);
    }

    /**
     * 获取某个视频的评论条数
     * @param videoId 视频主键
     * @return
     */
    public int countByVideoId(String videoId){
        return commentInfoMapper.countByVideoId(videoId);
    }

    /**
     * 删除评论表中的内容
     * @param userIdArr 用户id数组
     * @return
     */
    public int deleteByUserIdArr(@Param("userIdArr") String[] userIdArr){
        return commentInfoMapper.deleteByUserIdArr(userIdArr);
    }

}

